﻿///***************************************************************
/// 시  스  템 : Updms.Cfg.Dac
/// 단위시스템 : CFG
/// 계      층 : Data Access Layer
/// 프로그램명 : Cfg_Dac_UPDMS_CFG_BATCH_MGT
/// 파  일  명 : Cfg_Dac_UPDMS_CFG_BATCH_MGT.cs
/// 설      명 : 배치작업관리
///***************************************************************
/// 수정ID 일자       이름     내용
///---------------------------------------------------------------
/// CH001  2008-07-16 송시명   최초 작성
///***************************************************************
using System.Data;
using System.Data.SqlClient;
using System.EnterpriseServices;
using System.Runtime.InteropServices;

using SMFramework.Data;


namespace Updms.Cfg.Dac
{
	[ComVisible(true)]
	[Transaction(TransactionOption.Supported)]
	[JustInTimeActivation(true)]
	public class Cfg_Dac_UPDMS_CFG_BATCH_MGT : Base.AppFramework.DacBase
	{
		public Cfg_Dac_UPDMS_CFG_BATCH_MGT()
		{
		}

		#region NT [GetSearchCount]
		
		[AutoComplete]
		public int GetSearchCount(DataPack lo_dp)
		{
			string ls_sql = "usp_UPDMS_CFG_BATCH_MGT_Get_Search_Count";
			
			SqlParameter[] paramArray = lo_dp.ToSqlParameters();
			
			return (int)_agent.ExecuteScalar(ls_sql, paramArray, CommandType.StoredProcedure);
		}
		
		#endregion

		#region NT [SelectProcess]
		
		[AutoComplete]
		public DataSet SelectProcess(DataPack lo_dp)
		{
			string ls_sql = "usp_UPDMS_CFG_BATCH_MGT_Select_Paging";

			SqlParameter[] paramArray = lo_dp.ToSqlParameters();

			DataSet ds = new DataSet();
			return _agent.Fill(ls_sql, "UPDMS_CFG_BATCH_MGT", ds, paramArray, CommandType.StoredProcedure);
		}
		
		#endregion

		#region NT [ExecDbBackUp]

		[AutoComplete]
		public int ExecDbBackUp(string ls_file_path, string ls_db)
		{
			string ls_sql =
				" BACKUP DATABASE " + ls_db + " " +
				" TO DISK = '" + ls_file_path + "' " +
				" WITH FORMAT, " +
				" NAME = 'Full Backup of " + ls_db + "' ";

			return (int)_agent.ExecuteNonQuery(ls_sql);
		}

		#endregion

		#region RT [Insert]
		
		[AutoComplete]
		public int Insert(DataPack lo_dp)
		{
			string ls_sql = "usp_UPDMS_CFG_BATCH_MGT_Insert";

			SqlParameter[] paramArray = lo_dp.ToSqlParameters();
			return _agent.ExecuteNonQuery(ls_sql, paramArray, CommandType.StoredProcedure);
		}
		
		#endregion

		#region RT [Update]
		
		[AutoComplete]
		public int Update(DataPack lo_dp)
		{
			string ls_sql = "usp_UPDMS_CFG_BATCH_MGT_Update";			
			
			SqlParameter[] paramArray = lo_dp.ToSqlParameters();
			return _agent.ExecuteNonQuery(ls_sql, paramArray, CommandType.StoredProcedure);
		}
		
		#endregion

		#region RT [Delete]
		
		[AutoComplete]
		public int Delete(string ls_xml)
		{
			string ls_sql = "usp_UPDMS_CFG_BATCH_MGT_Delete";

			SqlParameter[] paramArray =
			{
				new SqlParameter("ls_xml", ls_xml)
			};
			
			return _agent.ExecuteNonQuery(ls_sql, paramArray, CommandType.StoredProcedure);
		}
		
		#endregion		
		
		#region RT [SetFavoriteYn]
		/// <summary>
		/// 즐겨찾기를 설정/해제 한다
		/// </summary>
		/// <param name="lo_dp"></param>
		/// <returns></returns>
		[AutoComplete]
		public int SetFavoriteYn(DataPack lo_dp)
		{
			string strSql = "usp_UPDMS_CFG_BATCH_MGT_Set_Favorite_Yn";

			SqlParameter[] paramArray = lo_dp.ToSqlParameters();
			return _agent.ExecuteNonQuery(strSql, paramArray, CommandType.StoredProcedure);
		}

		#endregion
	}
}
